package cn.linkedcare;

import android.widget.Toast;
import android.content.Intent;
import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.CallbackContext;
import org.json.JSONArray;
import org.json.JSONException;
import android.util.Log;

public class Scrm extends CordovaPlugin {
    public static final String ACTION_GET_NAME = "getName";
    @Override 
    public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
        try{
            if(ACTION_GET_NAME.equals(action)){
                cordova.getActivity().startActivity(new Intent(cordova.getActivity(), TestActivity.class));
                try {
                    String arg = args.getString(0);
                    Log.v("xiongyun", "arg ================" + arg);
                    //callbackContext.success("张三");
                    //Toast.makeText(cordova.getActivity(), arg, Toast.LENGTH_SHORT);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                //callbackContext.success("张三");
                return true;
            }
            //callbackContext.error("action是不getName");
            return false;
        }catch(Exception e){
            System.out.println("异常信息: " + e.getMessage());
            callbackContext.error(e.getMessage());
            return false;
        }
    }
}